{
 "nbformat": 4,
 "nbformat_minor": 0,
 "metadata": {
  "colab": {
   "provenance": [],
   "machine_shape": "hm",
   "gpuType": "T4",
   "authorship_tag": "ABX9TyP7WypZdPm4HqnzQGpYrpjv"
  },
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3"
  },
  "language_info": {
   "name": "python"
  },
  "accelerator": "GPU"
 },
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "![JohnSnowLabs](https://nlp.johnsnowlabs.com/assets/images/logo.png)\n",
    "\n",
    "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/JohnSnowLabs/nlu/blob/master/examples/colab/healthcare/entity_resolution/NLU_atc_resolver_pipeline.ipynb)\n",
    "\n",
    "# Pipeline for Anatomic Therapeutic Chemical (ATC) Sentence Entity Resolver\n",
    "\n",
    "This advanced pipeline extracts `DRUG` entities from clinical texts and utilizes the `sbiobert_base_cased_mli` Sentence Bert Embeddings to map these entities to their corresponding Anatomic Therapeutic Chemical (ATC) codes."
   ],
   "metadata": {
    "id": "iCMtX6J2DMR_"
   }
  },
  {
   "cell_type": "code",
   "source": [
    "import json, os\n",
    "from google.colab import files\n",
    "\n",
    "if 'spark_jsl.json' not in os.listdir():\n",
    "  license_keys = files.upload()\n",
    "  os.rename(list(license_keys.keys())[0], 'spark_jsl.json')\n",
    "\n",
    "with open('spark_jsl.json') as f:\n",
    "    license_keys = json.load(f)\n",
    "\n",
    "# Defining license key-value pairs as local variables\n",
    "locals().update(license_keys)\n",
    "os.environ.update(license_keys)"
   ],
   "metadata": {
    "id": "XOMnwBbKEwaV",
    "executionInfo": {
     "status": "ok",
     "timestamp": 1712296009311,
     "user_tz": 240,
     "elapsed": 291,
     "user": {
      "displayName": "Samed Koçer",
      "userId": "16161902236051002702"
     }
    }
   },
   "execution_count": 1,
   "outputs": []
  },
  {
   "cell_type": "code",
   "source": [
    "# Installing pyspark and spark-nlp\n",
    "! pip install --upgrade -q pyspark==3.1.2 spark-nlp==$PUBLIC_VERSION\n",
    "\n",
    "# Installing NLU\n",
    "! pip install --upgrade --q nlu --no-dependencies\n",
    "\n",
    "# Installing Spark NLP Healthcare\n",
    "! pip install --upgrade -q spark-nlp-jsl==$JSL_VERSION  --extra-index-url https://pypi.johnsnowlabs.com/$SECRET\n",
    "\n",
    "# Installing Spark NLP Display Library for visualization\n",
    "! pip install -q spark-nlp-display"
   ],
   "metadata": {
    "id": "qD1uNIZBExuZ"
   },
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "code",
   "source": [
    "import json\n",
    "import os\n",
    "\n",
    "import sparknlp\n",
    "import sparknlp_jsl\n",
    "import nlu\n",
    "\n",
    "from sparknlp.base import *\n",
    "from sparknlp.annotator import *\n",
    "from sparknlp_jsl.annotator import *\n",
    "\n",
    "from pyspark.sql import SparkSession\n",
    "from pyspark.sql import functions as F\n",
    "from pyspark.ml import Pipeline,PipelineModel\n",
    "\n",
    "import pandas as pd\n",
    "pd.set_option('display.max_colwidth', 200)\n",
    "\n",
    "import warnings\n",
    "warnings.filterwarnings('ignore')\n",
    "\n",
    "params = {\"spark.driver.memory\":\"16G\",\n",
    "          \"spark.kryoserializer.buffer.max\":\"2000M\",\n",
    "          \"spark.driver.maxResultSize\":\"2000M\"}\n",
    "\n",
    "print(\"Spark NLP Version :\", sparknlp.version())\n",
    "print(\"Spark NLP_JSL Version :\", sparknlp_jsl.version())\n",
    "\n",
    "spark = sparknlp_jsl.start(license_keys['SECRET'],params=params)\n",
    "\n",
    "spark"
   ],
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 254
    },
    "id": "40b-61cYExsq",
    "executionInfo": {
     "status": "ok",
     "timestamp": 1712296022891,
     "user_tz": 240,
     "elapsed": 9385,
     "user": {
      "displayName": "Samed Koçer",
      "userId": "16161902236051002702"
     }
    },
    "outputId": "a034553c-892c-4fda-fabe-98af636deb46"
   },
   "execution_count": 2,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Spark NLP Version : 5.3.1\n",
      "Spark NLP_JSL Version : 5.3.1\n"
     ]
    },
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<pyspark.sql.session.SparkSession at 0x7e154c5a55a0>"
      ],
      "text/html": [
       "\n",
       "            <div>\n",
       "                <p><b>SparkSession - in-memory</b></p>\n",
       "                \n",
       "        <div>\n",
       "            <p><b>SparkContext</b></p>\n",
       "\n",
       "            <p><a href=\"http://33b2f6c5f321:4040\">Spark UI</a></p>\n",
       "\n",
       "            <dl>\n",
       "              <dt>Version</dt>\n",
       "                <dd><code>v3.1.2</code></dd>\n",
       "              <dt>Master</dt>\n",
       "                <dd><code>local[*]</code></dd>\n",
       "              <dt>AppName</dt>\n",
       "                <dd><code>Spark NLP Licensed</code></dd>\n",
       "            </dl>\n",
       "        </div>\n",
       "        \n",
       "            </div>\n",
       "        "
      ]
     },
     "metadata": {},
     "execution_count": 2
    }
   ]
  },
  {
   "cell_type": "code",
   "source": [
    "pipe = nlu.load(\"en.resolve.atc_pipeline\")"
   ],
   "metadata": {
    "id": "NZ-iQBrHExqN",
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "executionInfo": {
     "status": "ok",
     "timestamp": 1712296214141,
     "user_tz": 240,
     "elapsed": 174923,
     "user": {
      "displayName": "Samed Koçer",
      "userId": "16161902236051002702"
     }
    },
    "outputId": "003104d8-4ae6-49e6-dc35-0b643e2873b0"
   },
   "execution_count": 3,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "atc_resolver_pipeline download started this may take some time.\n",
      "Approx size to download 2 GB\n",
      "[OK!]\n"
     ]
    }
   ]
  },
  {
   "cell_type": "code",
   "source": [
    "text = [\"\"\"She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg. She has a history of taking magnesium hydroxide.\"\"\"]"
   ],
   "metadata": {
    "id": "aGxTr1q8ExoQ",
    "executionInfo": {
     "status": "ok",
     "timestamp": 1712296219412,
     "user_tz": 240,
     "elapsed": 180,
     "user": {
      "displayName": "Samed Koçer",
      "userId": "16161902236051002702"
     }
    }
   },
   "execution_count": 4,
   "outputs": []
  },
  {
   "cell_type": "code",
   "source": [
    "df = pipe.predict(text)"
   ],
   "metadata": {
    "id": "z0WiMneiE2Y5",
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "executionInfo": {
     "status": "ok",
     "timestamp": 1712296231029,
     "user_tz": 240,
     "elapsed": 10283,
     "user": {
      "displayName": "Samed Koçer",
      "userId": "16161902236051002702"
     }
    },
    "outputId": "a3534b5a-c4b9-4b79-f900-afdb7772429f"
   },
   "execution_count": 5,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "\u001B[91m🚨 Your Spark-Healthcare is outdated, installed==5.3.1 but latest version==5.3.0\n",
      "You can run \u001B[92m nlp.install() \u001B[39mto update Spark-Healthcare\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    }
   ]
  },
  {
   "cell_type": "code",
   "source": [
    "df"
   ],
   "metadata": {
    "id": "6hqhJur1E2XB",
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "executionInfo": {
     "status": "ok",
     "timestamp": 1712296256560,
     "user_tz": 240,
     "elapsed": 671,
     "user": {
      "displayName": "Samed Koçer",
      "userId": "16161902236051002702"
     }
    },
    "outputId": "e7dea1be-a9f3-49b4-865d-662e357297d2"
   },
   "execution_count": 6,
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "                                                                                                                                                                        document  \\\n",
       "0  She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg. She has a history of taking magnesium hydroxide.   \n",
       "0  She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg. She has a history of taking magnesium hydroxide.   \n",
       "0  She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg. She has a history of taking magnesium hydroxide.   \n",
       "\n",
       "    entities_ner_chunk entities_ner_chunk_class entities_ner_chunk_confidence  \\\n",
       "0    hydrogen peroxide                     DRUG                       0.90765   \n",
       "0          amoxicillin                      NaN                        0.9995   \n",
       "0  magnesium hydroxide                      NaN                        0.9382   \n",
       "\n",
       "  entities_ner_chunk_origin_chunk entities_ner_chunk_origin_sentence  \\\n",
       "0                               0                                  0   \n",
       "0                             NaN                                NaN   \n",
       "0                             NaN                                NaN   \n",
       "\n",
       "  resolution_atc_code resolution_atc_code_confidence  \\\n",
       "0             A01AB02                         0.9985   \n",
       "0             J01CA04                         0.9961   \n",
       "0             A02AA04                         0.9963   \n",
       "\n",
       "  resolution_atc_code_distance  \\\n",
       "0                       0.0000   \n",
       "0                       0.0000   \n",
       "0                       0.0000   \n",
       "\n",
       "                                                                                                                                                                          resolution_atc_code_k_aux_labels  \\\n",
       "0  [[ATC 5th, ATC 5th, ATC 4th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 4th, ATC 5th, ATC 5th], [ATC 5th, ATC 5th, ATC...   \n",
       "0  [[ATC 5th, ATC 5th, ATC 4th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 4th, ATC 5th, ATC 5th], [ATC 5th, ATC 5th, ATC...   \n",
       "0  [[ATC 5th, ATC 5th, ATC 4th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 4th, ATC 5th, ATC 5th], [ATC 5th, ATC 5th, ATC...   \n",
       "\n",
       "   ...  \\\n",
       "0  ...   \n",
       "0  ...   \n",
       "0  ...   \n",
       "\n",
       "                                                                                                                                                                       resolution_atc_code_k_cos_distances  \\\n",
       "0  [[0.0000, 0.0893, 0.1199, 0.1254, 0.1337, 0.1608, 0.1858, 0.1948, 0.2023, 0.2076, 0.1955, 0.2121, 0.2130, 0.2139, 0.2291, 0.2172, 0.2239, 0.2208, 0.2142], [0.0000, 0.0820, 0.0967, 0.1006, 0.1082, ...   \n",
       "0  [[0.0000, 0.0893, 0.1199, 0.1254, 0.1337, 0.1608, 0.1858, 0.1948, 0.2023, 0.2076, 0.1955, 0.2121, 0.2130, 0.2139, 0.2291, 0.2172, 0.2239, 0.2208, 0.2142], [0.0000, 0.0820, 0.0967, 0.1006, 0.1082, ...   \n",
       "0  [[0.0000, 0.0893, 0.1199, 0.1254, 0.1337, 0.1608, 0.1858, 0.1948, 0.2023, 0.2076, 0.1955, 0.2121, 0.2130, 0.2139, 0.2291, 0.2172, 0.2239, 0.2208, 0.2142], [0.0000, 0.0820, 0.0967, 0.1006, 0.1082, ...   \n",
       "\n",
       "                                                                                                                                                                           resolution_atc_code_k_distances  \\\n",
       "0  [[0.0000, 7.2638, 8.5359, 8.6054, 8.8623, 9.8050, 10.4785, 10.6252, 10.8362, 10.8516, 10.8802, 11.0478, 11.2217, 11.2228, 11.3405, 11.3486, 11.3811, 11.4295, 11.4679], [0.0000, 6.9141, 7.4772, 7.6...   \n",
       "0  [[0.0000, 7.2638, 8.5359, 8.6054, 8.8623, 9.8050, 10.4785, 10.6252, 10.8362, 10.8516, 10.8802, 11.0478, 11.2217, 11.2228, 11.3405, 11.3486, 11.3811, 11.4295, 11.4679], [0.0000, 6.9141, 7.4772, 7.6...   \n",
       "0  [[0.0000, 7.2638, 8.5359, 8.6054, 8.8623, 9.8050, 10.4785, 10.6252, 10.8362, 10.8516, 10.8802, 11.0478, 11.2217, 11.2228, 11.3405, 11.3486, 11.3811, 11.4295, 11.4679], [0.0000, 6.9141, 7.4772, 7.6...   \n",
       "\n",
       "                                                                                                                                                                          resolution_atc_code_k_resolution  \\\n",
       "0  [[hydrogen peroxide , hydrogen peroxide; otic, Peroxides, ethanol / hydrogen peroxide , benzoyl peroxide , oxybate , diazoxide , magnesium peroxide, hydroxyzine , sucroferric oxyhydroxide , carbon...   \n",
       "0  [[hydrogen peroxide , hydrogen peroxide; otic, Peroxides, ethanol / hydrogen peroxide , benzoyl peroxide , oxybate , diazoxide , magnesium peroxide, hydroxyzine , sucroferric oxyhydroxide , carbon...   \n",
       "0  [[hydrogen peroxide , hydrogen peroxide; otic, Peroxides, ethanol / hydrogen peroxide , benzoyl peroxide , oxybate , diazoxide , magnesium peroxide, hydroxyzine , sucroferric oxyhydroxide , carbon...   \n",
       "\n",
       "  resolution_atc_code_origin_sentence resolution_atc_code_resolved_text  \\\n",
       "0                                   0                hydrogen peroxide    \n",
       "0                                   0                      amoxicillin    \n",
       "0                                   1              magnesium hydroxide    \n",
       "\n",
       "  resolution_atc_code_target_text resolution_atc_code_token  \\\n",
       "0               hydrogen peroxide         hydrogen peroxide   \n",
       "0                     amoxicillin               amoxicillin   \n",
       "0             magnesium hydroxide       magnesium hydroxide   \n",
       "\n",
       "                                                                                                                                                                        sentence_dl  \\\n",
       "0  [She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg., She has a history of taking magnesium hydroxide.]   \n",
       "0  [She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg., She has a history of taking magnesium hydroxide.]   \n",
       "0  [She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg., She has a history of taking magnesium hydroxide.]   \n",
       "\n",
       "                                                                                                                                                                                       sentence_embeddings  \\\n",
       "0  [[0.23269009590148926, -0.2680894732475281, -0.7400643229484558, -0.3144417405128479, 0.5825711488723755, -0.10474076122045517, -0.01933845318853855, 0.24036844074726105, 0.3761536180973053, 0.856...   \n",
       "0  [[0.23269009590148926, -0.2680894732475281, -0.7400643229484558, -0.3144417405128479, 0.5825711488723755, -0.10474076122045517, -0.01933845318853855, 0.24036844074726105, 0.3761536180973053, 0.856...   \n",
       "0  [[0.23269009590148926, -0.2680894732475281, -0.7400643229484558, -0.3144417405128479, 0.5825711488723755, -0.10474076122045517, -0.01933845318853855, 0.24036844074726105, 0.3761536180973053, 0.856...   \n",
       "\n",
       "                                                                                                                                                                            word_embedding_word_embeddings  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -0.10418396443128586, -0.5357521772384644, -0.06646879762411118, -0.444497287273407, -0.5000978708267212, -0.5944756269454956, 0.1369660645723343, 0.04...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -0.10418396443128586, -0.5357521772384644, -0.06646879762411118, -0.444497287273407, -0.5000978708267212, -0.5944756269454956, 0.1369660645723343, 0.04...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -0.10418396443128586, -0.5357521772384644, -0.06646879762411118, -0.444497287273407, -0.5000978708267212, -0.5944756269454956, 0.1369660645723343, 0.04...  \n",
       "\n",
       "[3 rows x 22 columns]"
      ],
      "text/html": [
       "\n",
       "  <div id=\"df-89e74a7d-8c09-4d0b-8d4b-dee48cf4adc1\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>entities_ner_chunk</th>\n",
       "      <th>entities_ner_chunk_class</th>\n",
       "      <th>entities_ner_chunk_confidence</th>\n",
       "      <th>entities_ner_chunk_origin_chunk</th>\n",
       "      <th>entities_ner_chunk_origin_sentence</th>\n",
       "      <th>resolution_atc_code</th>\n",
       "      <th>resolution_atc_code_confidence</th>\n",
       "      <th>resolution_atc_code_distance</th>\n",
       "      <th>resolution_atc_code_k_aux_labels</th>\n",
       "      <th>...</th>\n",
       "      <th>resolution_atc_code_k_cos_distances</th>\n",
       "      <th>resolution_atc_code_k_distances</th>\n",
       "      <th>resolution_atc_code_k_resolution</th>\n",
       "      <th>resolution_atc_code_origin_sentence</th>\n",
       "      <th>resolution_atc_code_resolved_text</th>\n",
       "      <th>resolution_atc_code_target_text</th>\n",
       "      <th>resolution_atc_code_token</th>\n",
       "      <th>sentence_dl</th>\n",
       "      <th>sentence_embeddings</th>\n",
       "      <th>word_embedding_word_embeddings</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg. She has a history of taking magnesium hydroxide.</td>\n",
       "      <td>hydrogen peroxide</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>0.90765</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>A01AB02</td>\n",
       "      <td>0.9985</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>[[ATC 5th, ATC 5th, ATC 4th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 4th, ATC 5th, ATC 5th], [ATC 5th, ATC 5th, ATC...</td>\n",
       "      <td>...</td>\n",
       "      <td>[[0.0000, 0.0893, 0.1199, 0.1254, 0.1337, 0.1608, 0.1858, 0.1948, 0.2023, 0.2076, 0.1955, 0.2121, 0.2130, 0.2139, 0.2291, 0.2172, 0.2239, 0.2208, 0.2142], [0.0000, 0.0820, 0.0967, 0.1006, 0.1082, ...</td>\n",
       "      <td>[[0.0000, 7.2638, 8.5359, 8.6054, 8.8623, 9.8050, 10.4785, 10.6252, 10.8362, 10.8516, 10.8802, 11.0478, 11.2217, 11.2228, 11.3405, 11.3486, 11.3811, 11.4295, 11.4679], [0.0000, 6.9141, 7.4772, 7.6...</td>\n",
       "      <td>[[hydrogen peroxide , hydrogen peroxide; otic, Peroxides, ethanol / hydrogen peroxide , benzoyl peroxide , oxybate , diazoxide , magnesium peroxide, hydroxyzine , sucroferric oxyhydroxide , carbon...</td>\n",
       "      <td>0</td>\n",
       "      <td>hydrogen peroxide</td>\n",
       "      <td>hydrogen peroxide</td>\n",
       "      <td>hydrogen peroxide</td>\n",
       "      <td>[She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg., She has a history of taking magnesium hydroxide.]</td>\n",
       "      <td>[[0.23269009590148926, -0.2680894732475281, -0.7400643229484558, -0.3144417405128479, 0.5825711488723755, -0.10474076122045517, -0.01933845318853855, 0.24036844074726105, 0.3761536180973053, 0.856...</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -0.10418396443128586, -0.5357521772384644, -0.06646879762411118, -0.444497287273407, -0.5000978708267212, -0.5944756269454956, 0.1369660645723343, 0.04...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg. She has a history of taking magnesium hydroxide.</td>\n",
       "      <td>amoxicillin</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.9995</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>J01CA04</td>\n",
       "      <td>0.9961</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>[[ATC 5th, ATC 5th, ATC 4th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 4th, ATC 5th, ATC 5th], [ATC 5th, ATC 5th, ATC...</td>\n",
       "      <td>...</td>\n",
       "      <td>[[0.0000, 0.0893, 0.1199, 0.1254, 0.1337, 0.1608, 0.1858, 0.1948, 0.2023, 0.2076, 0.1955, 0.2121, 0.2130, 0.2139, 0.2291, 0.2172, 0.2239, 0.2208, 0.2142], [0.0000, 0.0820, 0.0967, 0.1006, 0.1082, ...</td>\n",
       "      <td>[[0.0000, 7.2638, 8.5359, 8.6054, 8.8623, 9.8050, 10.4785, 10.6252, 10.8362, 10.8516, 10.8802, 11.0478, 11.2217, 11.2228, 11.3405, 11.3486, 11.3811, 11.4295, 11.4679], [0.0000, 6.9141, 7.4772, 7.6...</td>\n",
       "      <td>[[hydrogen peroxide , hydrogen peroxide; otic, Peroxides, ethanol / hydrogen peroxide , benzoyl peroxide , oxybate , diazoxide , magnesium peroxide, hydroxyzine , sucroferric oxyhydroxide , carbon...</td>\n",
       "      <td>0</td>\n",
       "      <td>amoxicillin</td>\n",
       "      <td>amoxicillin</td>\n",
       "      <td>amoxicillin</td>\n",
       "      <td>[She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg., She has a history of taking magnesium hydroxide.]</td>\n",
       "      <td>[[0.23269009590148926, -0.2680894732475281, -0.7400643229484558, -0.3144417405128479, 0.5825711488723755, -0.10474076122045517, -0.01933845318853855, 0.24036844074726105, 0.3761536180973053, 0.856...</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -0.10418396443128586, -0.5357521772384644, -0.06646879762411118, -0.444497287273407, -0.5000978708267212, -0.5944756269454956, 0.1369660645723343, 0.04...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg. She has a history of taking magnesium hydroxide.</td>\n",
       "      <td>magnesium hydroxide</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.9382</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>A02AA04</td>\n",
       "      <td>0.9963</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>[[ATC 5th, ATC 5th, ATC 4th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 5th, ATC 4th, ATC 5th, ATC 5th], [ATC 5th, ATC 5th, ATC...</td>\n",
       "      <td>...</td>\n",
       "      <td>[[0.0000, 0.0893, 0.1199, 0.1254, 0.1337, 0.1608, 0.1858, 0.1948, 0.2023, 0.2076, 0.1955, 0.2121, 0.2130, 0.2139, 0.2291, 0.2172, 0.2239, 0.2208, 0.2142], [0.0000, 0.0820, 0.0967, 0.1006, 0.1082, ...</td>\n",
       "      <td>[[0.0000, 7.2638, 8.5359, 8.6054, 8.8623, 9.8050, 10.4785, 10.6252, 10.8362, 10.8516, 10.8802, 11.0478, 11.2217, 11.2228, 11.3405, 11.3486, 11.3811, 11.4295, 11.4679], [0.0000, 6.9141, 7.4772, 7.6...</td>\n",
       "      <td>[[hydrogen peroxide , hydrogen peroxide; otic, Peroxides, ethanol / hydrogen peroxide , benzoyl peroxide , oxybate , diazoxide , magnesium peroxide, hydroxyzine , sucroferric oxyhydroxide , carbon...</td>\n",
       "      <td>1</td>\n",
       "      <td>magnesium hydroxide</td>\n",
       "      <td>magnesium hydroxide</td>\n",
       "      <td>magnesium hydroxide</td>\n",
       "      <td>[She was immediately given hydrogen peroxide 30 mg and amoxicillin twice daily for 10 days to treat the infection on her leg., She has a history of taking magnesium hydroxide.]</td>\n",
       "      <td>[[0.23269009590148926, -0.2680894732475281, -0.7400643229484558, -0.3144417405128479, 0.5825711488723755, -0.10474076122045517, -0.01933845318853855, 0.24036844074726105, 0.3761536180973053, 0.856...</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -0.10418396443128586, -0.5357521772384644, -0.06646879762411118, -0.444497287273407, -0.5000978708267212, -0.5944756269454956, 0.1369660645723343, 0.04...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 22 columns</p>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-89e74a7d-8c09-4d0b-8d4b-dee48cf4adc1')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-89e74a7d-8c09-4d0b-8d4b-dee48cf4adc1 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-89e74a7d-8c09-4d0b-8d4b-dee48cf4adc1');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-288988b1-58e4-4289-8ba8-78d574920fb3\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-288988b1-58e4-4289-8ba8-78d574920fb3')\"\n",
       "            title=\"Suggest charts\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-288988b1-58e4-4289-8ba8-78d574920fb3 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "\n",
       "  <div id=\"id_c3809efe-86e7-41d4-a589-e6f26197cd25\">\n",
       "    <style>\n",
       "      .colab-df-generate {\n",
       "        background-color: #E8F0FE;\n",
       "        border: none;\n",
       "        border-radius: 50%;\n",
       "        cursor: pointer;\n",
       "        display: none;\n",
       "        fill: #1967D2;\n",
       "        height: 32px;\n",
       "        padding: 0 0 0 0;\n",
       "        width: 32px;\n",
       "      }\n",
       "\n",
       "      .colab-df-generate:hover {\n",
       "        background-color: #E2EBFA;\n",
       "        box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "        fill: #174EA6;\n",
       "      }\n",
       "\n",
       "      [theme=dark] .colab-df-generate {\n",
       "        background-color: #3B4455;\n",
       "        fill: #D2E3FC;\n",
       "      }\n",
       "\n",
       "      [theme=dark] .colab-df-generate:hover {\n",
       "        background-color: #434B5C;\n",
       "        box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "        filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "        fill: #FFFFFF;\n",
       "      }\n",
       "    </style>\n",
       "    <button class=\"colab-df-generate\" onclick=\"generateWithVariable('df')\"\n",
       "            title=\"Generate code using this dataframe.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "       width=\"24px\">\n",
       "    <path d=\"M7,19H8.4L18.45,9,17,7.55,7,17.6ZM5,21V16.75L18.45,3.32a2,2,0,0,1,2.83,0l1.4,1.43a1.91,1.91,0,0,1,.58,1.4,1.91,1.91,0,0,1-.58,1.4L9.25,21ZM18.45,9,17,7.55Zm-12,3A5.31,5.31,0,0,0,4.9,8.1,5.31,5.31,0,0,0,1,6.5,5.31,5.31,0,0,0,4.9,4.9,5.31,5.31,0,0,0,6.5,1,5.31,5.31,0,0,0,8.1,4.9,5.31,5.31,0,0,0,12,6.5,5.46,5.46,0,0,0,6.5,12Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "    <script>\n",
       "      (() => {\n",
       "      const buttonEl =\n",
       "        document.querySelector('#id_c3809efe-86e7-41d4-a589-e6f26197cd25 button.colab-df-generate');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      buttonEl.onclick = () => {\n",
       "        google.colab.notebook.generateWithVariable('df');\n",
       "      }\n",
       "      })();\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "application/vnd.google.colaboratory.intrinsic+json": {
       "type": "dataframe",
       "variable_name": "df"
      }
     },
     "metadata": {},
     "execution_count": 6
    }
   ]
  },
  {
   "cell_type": "code",
   "source": [
    "df[[ \"entities_ner_chunk\",\"resolution_atc_code\"]]"
   ],
   "metadata": {
    "id": "eQPMIZaJE2Ur",
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 143
    },
    "executionInfo": {
     "status": "ok",
     "timestamp": 1712296720703,
     "user_tz": 240,
     "elapsed": 162,
     "user": {
      "displayName": "Samed Koçer",
      "userId": "16161902236051002702"
     }
    },
    "outputId": "f48a99d4-68d5-4ab9-95f0-51de684cea2d"
   },
   "execution_count": 9,
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "    entities_ner_chunk resolution_atc_code\n",
       "0    hydrogen peroxide             A01AB02\n",
       "0          amoxicillin             J01CA04\n",
       "0  magnesium hydroxide             A02AA04"
      ],
      "text/html": [
       "\n",
       "  <div id=\"df-4cf514f4-b70a-46f0-b49b-97fb27f081f8\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>entities_ner_chunk</th>\n",
       "      <th>resolution_atc_code</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>hydrogen peroxide</td>\n",
       "      <td>A01AB02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>amoxicillin</td>\n",
       "      <td>J01CA04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>magnesium hydroxide</td>\n",
       "      <td>A02AA04</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-4cf514f4-b70a-46f0-b49b-97fb27f081f8')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-4cf514f4-b70a-46f0-b49b-97fb27f081f8 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-4cf514f4-b70a-46f0-b49b-97fb27f081f8');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-dfff7e96-ed56-4f54-b388-3a9719796483\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-dfff7e96-ed56-4f54-b388-3a9719796483')\"\n",
       "            title=\"Suggest charts\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-dfff7e96-ed56-4f54-b388-3a9719796483 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "application/vnd.google.colaboratory.intrinsic+json": {
       "type": "dataframe",
       "summary": "{\n  \"name\": \"df[[ \\\"entities_ner_chunk\\\",\\\"resolution_atc_code\\\"]]\",\n  \"rows\": 3,\n  \"fields\": [\n    {\n      \"column\": \"entities_ner_chunk\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 3,\n        \"samples\": [\n          \"hydrogen peroxide\",\n          \"amoxicillin\",\n          \"magnesium hydroxide\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"resolution_atc_code\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 3,\n        \"samples\": [\n          \"A01AB02\",\n          \"J01CA04\",\n          \"A02AA04\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    }\n  ]\n}"
      }
     },
     "metadata": {},
     "execution_count": 9
    }
   ]
  }
 ]
}
